﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using Loki.Data;

namespace Loki.Model
{
	public abstract class AtomicEntity<TEntityKey, TModelType> : Entity<TModelType>, IAtomicEntity<TEntityKey> 
	{
		static PropertyChangedEventArgs _IDChangeArgs = ObservableHelper.CreateArgs<AtomicEntity<TEntityKey, TModelType>>(x => x.ID);

		public TEntityKey ID { get { return _ID; } set { if (!Object.Equals(value, _ID)) { _ID = value; NotifyChangedAndDirty(_IDChangeArgs); } } }
		protected TEntityKey _ID;


		public AtomicEntity()
			: base()
		{

		}

		public AtomicEntity(AtomicEntity<TEntityKey, TModelType> P_Clone)
			: base(P_Clone)
		{
			_ID = P_Clone.ID;
		}

		public AtomicEntity(IDataEntity<TEntityKey> P_Clone)
			: base()
		{
			_ID = P_Clone.PK;
		}
	}
}
